#include<cstdio>
using namespace std;
const int N = 8005;
int n, q, op, x, v, a[N], ans[N];
inline int read() {
	int an = 0;
	char ch = getchar();
	for (; ch < 48 || ch > 57 ; ch = getchar());
	for (; ch > 47 && ch < 58 ; ch = getchar())
		an = (an << 3) + (an << 1) + ch - 48;
	return an;
}
int main() {
	freopen("sort.in","r",stdin);
	freopen("sort.out","w",stdout);
	n = read();
	q = read();
	for (int i = 1 ; i <= n ; i++) {
		a[i] = read();
		for (int j = 1 ; j < i ; j++) {
			if (a[i] == a[j])ans[i]++;
			if (a[i] < a[j])ans[j]++;
			if (a[i] > a[j])ans[i]++;
		}
	}
	while (q--) {
		op = read();
		if (op == 1) {
			x = read();
			v = read();
			ans[x] = 0;
			for (int i(1) ; i <= n ; i++) {
				if (i == x)continue;
				if (a[i] > a[x])ans[i]--;
				else if (a[i] == a[x] && i > x)ans[i]--;
				if (a[i] > v)ans[i]++;
				if (v > a[i])ans[x]++;
				if (a[i] == v && i < x)ans[x]++;
				if (a[i] == v && i > x)ans[i]++;
			}
			a[x] = v;
		}
		else {
			x = read();
			printf("%d\n", ans[x] + 1);
		}
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}
